package org.neuedu.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import jakarta.annotation.Resource;
import org.neuedu.common.ResultJson;
import org.neuedu.entity.DrugInfo;
import org.neuedu.service.DrugInfoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lzw
 * @since 2024-11-19
 */
@RestController
@RequestMapping("/drugInfo")
public class DrugInfoController {
    @Resource
    DrugInfoService drugInfoService;
    @GetMapping("/list")
    ResultJson<List<DrugInfo>> list(String drugName, String mnemonicCode) {
        return ResultJson.success(drugInfoService.list(drugName, mnemonicCode));
    }
    @GetMapping("/listPage")
    ResultJson<IPage<DrugInfo>> list(Integer pageNo, Integer pageSize, String name) throws InterruptedException {
        return ResultJson.success(drugInfoService.listPage(pageNo, pageSize, name));
    }
    @GetMapping("/getById")
    ResultJson<DrugInfo> getById(Long id) {
        return ResultJson.success(drugInfoService.getById(id));
    }
    @PostMapping("/updateById")
    ResultJson<Boolean> updateById(Integer id, BigDecimal drugPrice, Long quantity) {
        return ResultJson.success(drugInfoService.update(id,drugPrice,quantity));
    }
}
